import pygame
import random

class Smallenemy(pygame.sprite.Sprite):
    def __init__(self,size):
        pygame.sprite.Sprite.__init__(self)

        self.width,self.height = size[0],size[1]
        self.image=pygame.image.load('images/enemy1.png').convert_alpha()
        self.rect = self.image.get_rect()
        self.rect.left,self.rect.top=random.randint(self.rect.width,self.width-self.rect.width),\
                                      random.randint(-5*self.height,0)
        self.speed = 2
        self.active = True
        self.image_downs = []
        self.image_downs.extend([\
            pygame.image.load('images/enemy1_down1.png').convert_alpha(),\
            pygame.image.load('images/enemy1_down2.png').convert_alpha(),\
            pygame.image.load('images/enemy1_down3.png').convert_alpha(),\
            pygame.image.load('images/enemy1_down4.png').convert_alpha(),\
            ])
        self.index=0
        self.mask=pygame.mask.from_surface(self.image)
        self.score = 1000
    def move(self):
        if self.rect.top < self.height:
            self.rect.top +=self.speed
        else:
            self.reset()

    def reset(self):
        self.rect.left,self.rect.top=random.randint(self.rect.width,self.width-self.rect.width),\
                                      random.randint(-5*self.height,0)
        self.index=0
        self.active = True
        
class Midenemy(pygame.sprite.Sprite):
    HP =8
    def __init__(self,size):
        pygame.sprite.Sprite.__init__(self)

        self.width,self.height = size[0],size[1]
        self.image=pygame.image.load('images/enemy2.png').convert_alpha()
        self.rect = self.image.get_rect()
        self.rect.left,self.rect.top=random.randint(self.rect.width,self.width-self.rect.width),\
                                      random.randint(-10*self.height,-self.height)
        self.hit_image = pygame.image.load('images/enemy2_hit.png').convert_alpha()
        self.speed = 1
        self.active = True
        self.image_downs = []
        self.image_downs.extend([\
            pygame.image.load('images/enemy2_down1.png').convert_alpha(),\
            pygame.image.load('images/enemy2_down2.png').convert_alpha(),\
            pygame.image.load('images/enemy2_down3.png').convert_alpha(),\
            pygame.image.load('images/enemy2_down4.png').convert_alpha(),\
            ])
        self.index=0
        self.mask=pygame.mask.from_surface(self.image)
        self.HP =Midenemy.HP
        self.hit =False
        self.score = 10000
    def move(self):
        if self.rect.top < self.height:
            self.rect.top +=self.speed
        else:
            self.reset()

    def reset(self):
        self.rect.left,self.rect.top=random.randint(self.rect.width,self.width-self.rect.width),\
                                      random.randint(-10*self.height,-self.height)
        self.index=0
        self.active = True
        self.HP =Midenemy.HP
class Bigenemy(pygame.sprite.Sprite):
    HP=20
    def __init__(self,size):
        pygame.sprite.Sprite.__init__(self)

        self.width,self.height = size[0],size[1]
        self.image1=pygame.image.load('images/enemy3_n1.png').convert_alpha()
        self.image2=pygame.image.load('images/enemy3_n2.png').convert_alpha()
        self.hit_image = pygame.image.load('images/enemy3_hit.png').convert_alpha()
        self.rect = self.image1.get_rect()
        self.rect.left,self.rect.top=random.randint(self.rect.width,self.width-self.rect.width),\
                                      random.randint(-15*self.height,-5*self.height)
        
        self.speed = 1
        self.active = True
        self.image_downs = []
        self.image_downs.extend([\
            pygame.image.load('images/enemy3_down1.png').convert_alpha(),\
            pygame.image.load('images/enemy3_down2.png').convert_alpha(),\
            pygame.image.load('images/enemy3_down3.png').convert_alpha(),\
            pygame.image.load('images/enemy3_down4.png').convert_alpha(),\
            pygame.image.load('images/enemy3_down5.png').convert_alpha(),\
            pygame.image.load('images/enemy3_down6.png').convert_alpha(),\

            ])
        self.mask=pygame.mask.from_surface(self.image1)
        self.index=0
        self.HP=Bigenemy.HP
        self.hit =False
        self.score = 50000
    def move(self):
        if self.rect.top < self.height:
            self.rect.top +=self.speed
        else:
            self.reset()

    def reset(self):
        self.rect.left,self.rect.top=random.randint(self.rect.width,self.width-self.rect.width),\
                                      random.randint(-15*self.height,-5*self.height)
        self.index=0
        self.active = True
        self.HP=Bigenemy.HP
